
//
//  BFFuncationController.m
//  beifang
//
//  Created by Apple on 17/4/18.
//  Copyright © 2017年 郭凯. All rights reserved.
//

#import "BFFuncationController.h"

@interface BFFuncationController ()<TZImagePickerControllerDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *imageView;
@property (nonatomic,strong)  TZImagePickerController *imagePickerVc;
@end

@implementation BFFuncationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


- (IBAction)uploadPhoto:(id)sender {
    TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:self];
    self.imagePickerVc = imagePickerVc;
    // 你可以通过block或者代理，来得到用户选择的照片.
        [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
//            [self sendPhoto:photos];
            [self sendOriginalPicture:photos];
        }];
     [self presentViewController:imagePickerVc animated:YES completion:nil];
}


// 发送图片
-(void)sendPhoto:(NSArray *)photos{
    NSString *url = @"http://192.168.1.106/shop/index.php/admin/index/upload";
    NSDictionary *dic = @{@"name":@"小明",
                          @"age":@(18)
                          };
    [[CLAFNTool shareTools]sendPhoto:url parameter:dic photos:photos progress:^(NSProgress *uploadProgress) {
      CGFloat totle =  uploadProgress.totalUnitCount;
        CGFloat num = uploadProgress.completedUnitCount;
        NSLog(@"进程=%lf  总共大小=%lf 上传大小=%lf",num/totle,totle,num);
    } success:^(id responseObject) {
        
        NSLog(@"%@",responseObject);
        
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}


// 系统原始发送数据
-(void)sendOriginalPicture:(NSArray *)photos{
    NSString *url = @"http://192.168.1.106/shop/index.php/admin/index/upload";
    NSDictionary *dic = @{@"name":@"小明",
                          @"age":@(18)
                          };
  [[CLAFNTool shareTools]postImage:url parameter:dic photos:photos progress:^(NSProgress *uploadProgress) {
     
  } success:^(id responseObject) {
     
  } failure:^(NSError *error) {
      
  }];
}

@end
